m = []
s = input()
f = 0
for e in s:
    if e == "(":
        m.append(e)
    elif e == ")" and m != []:
        a = m.pop(-1)
        if a != "(":
            print('False')
            f = 1
            break
    elif e == "[":
        m.append(e)
    elif e == "]" and m != []:
        a = m.pop(-1)
        if a != "[":
            print('False')
            f = 1
            break
    elif e == "{":
        m.append(e)
    elif e == "}" and m != []:
        a = m.pop(-1)
        if a != "{":
            print('False')
            f = 1
            break
    elif e == "<":
        m.append(e)
    elif e == ">" and m != []:
        a = m.pop(-1)
        if a != "<":
            print('False')
            f = 1
            break
    elif e == ")" or e == "]" or e == "}" or e == ">":
        print('False')
        f = 1
if f == 0 and len(m) == 0:
    print('True')
elif f == 0 and len(m) > 0:
    print('False')